{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Write a python Function for finding is a given number prime or not and do Unit Testing on it using PyLint & Unittest Library."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sympy\n",
    "\n",
    "def checkPrimeNumber(num):\n",
    "    if sympy.isprime(num):\n",
    "        return num\n",
    "    else:\n",
    "        return(\"No Prime\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "checkPrimeNumber(7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing check_pri.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile check_pri.py\n",
    "import sympy\n",
    "'''\n",
    "Module to check prime Number\n",
    "'''\n",
    "def checkPrimeNumber(num):\n",
    "    '''\n",
    "    Function to Check Prime takes a Input\n",
    "    '''\n",
    "    if sympy.isprime(num):\n",
    "        '''\n",
    "        if statement\n",
    "        '''\n",
    "        return num\n",
    "    else:\n",
    "        return \"No Prime\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "************* Module chPrime\n",
      "chPrime.py:1:0: C0103: Module name \"chPrime\" doesn't conform to snake_case naming style (invalid-name)\n",
      "chPrime.py:1:0: C0114: Missing module docstring (missing-module-docstring)\n",
      "chPrime.py:4:-1: W0105: String statement has no effect (pointless-string-statement)\n",
      "chPrime.py:5:0: C0103: Function name \"checkPrimeNumber\" doesn't conform to snake_case naming style (invalid-name)\n",
      "chPrime.py:9:4: R1705: Unnecessary \"else\" after \"return\" (no-else-return)\n",
      "\n",
      "-----------------------------------\n",
      "Your code has been rated at 1.67/10\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!pylint chPrime.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Overwriting check_prime.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile check_prime.py\n",
    "import unittest \n",
    "import check_pri\n",
    "\n",
    "class TestPrime(unittest.TestCase):\n",
    "    def checkprimeNumber(self):\n",
    "        num = 7\n",
    "        result = chPrime.checkPrimeNumber(num)\n",
    "        self.assertEqual(result,num)\n",
    "\n",
    "    def checkNotPrimenumber(self):\n",
    "        num= 8\n",
    "        result = chPrime.checkPrimeNumber(num)\n",
    "        self.assertEqual(result,\"No Prime\")\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    unittest.main()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\r\n",
      "----------------------------------------------------------------------\r\n",
      "Ran 0 tests in 0.000s\r\n",
      "\r\n",
      "OK\r\n"
     ]
    }
   ],
   "source": [
    "!python check_prime.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/Users/nvrsettle/Python FCS LetsUpgrade\r\n"
     ]
    }
   ],
   "source": [
    "!pwd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
